﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IsNormal
{
    internal class IsCollinear  //判断共线
    {
        
        public bool Isco(  double AX, double AY, double AZ,
                           double BX, double BY, double BZ,
                           double CX, double CY, double CZ)
        {
            // XY轴上的斜线
            double XY_ab = (CX - AX) * (BY - AY) / (BX - AX) + AY;
            double XY_ac = (BX - AX) * (CY - AY) / (CX - AX) + AY;
            double XY_bc = (AX - BX) * (CY - BY) / (CX - BX) + BY;
            // XZ轴上的斜线
            double XZ_ab = (CX - AX) * (BZ - AZ) / (BX - AX) + AZ;
            double XZ_ac = (BX - AX) * (CZ - AZ) / (CX - AX) + AZ;
            double XZ_bc = (AX - BX) * (CZ - BZ) / (CX - BX) + BZ;
            // YZ轴上的斜线
            double YZ_ab = (CY - AY) * (BZ - AZ) / (BY - AY) + AZ;
            double YZ_ac = (BY - AY) * (CZ - AZ) / (CY - AY) + AZ;
            double YZ_bc = (AY - BY) * (CZ - BZ) / (CY - BY) + BZ;


            if (AX==BX && AX==CX && AY==BY && AY==CY)  //  在Z轴上共线
            {
               return true;
            }
            else if(AX==BX && AX==CX && AZ==BZ && AZ==CZ) // 在y轴上共线
            {
                return true;
            }
            else if (AY==BY && AY==CY && AZ==BZ && AZ==CZ)  //在x轴上共线
            {
                return true;
            }
            else if (CY==XY_ab | BY == XY_ac | AY == XY_bc && AZ==0 & BZ==0 & CZ==0) // XY轴上的斜线
            {
                return true;
            }
            else if (CZ == XZ_ab | BZ == XZ_ac | AZ == XZ_bc && AY == 0 & BY == 0 & CY == 0) // XZ轴上的斜线
            {
                return true;
            }
            else if (CZ == YZ_ab | BZ == YZ_ac | AZ == YZ_bc && AX == 0 & BX == 0 & CX == 0) // YZ轴上的斜线
            {
                return true;
            }
            return false;
            
        }
    }
}
